package com.vzoom.logdesensitization.strategyimpl;

import com.vzoom.logdesensitization.DesensitizationStrategy;

public class AddressDesensitizationStrategy implements DesensitizationStrategy {
    @Override
    public String desensitization(Object origin) {
        String toString = String.valueOf(origin);
        if (origin == null) {
            return toString;
        }
        int length = toString.length();
        int index = 0;
        StringBuilder sb = new StringBuilder(length);
        char c;
        while (index < length) {
            c = toString.charAt(index++);
            if (c == '省' || c == '市' || c == '区' || c == '县' || c == '路' || c == '街' || c == '村') {
                sb.append(c);
            } else {
                sb.append('*');
            }
        }
        return sb.toString();
    }
}
